package com.example.project10;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * 书籍数据库帮助类
 * 负责创建和管理SQLite数据库
 */
public class BookDatabaseHelper extends SQLiteOpenHelper {
    
    private static final String DATABASE_NAME = "books.db";
    private static final int DATABASE_VERSION = 1;
    
    
    public BookDatabaseHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }
    
    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(DatabaseContract.BookEntry.CREATE_TABLE_BOOKS);
    }
    
    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("DROP TABLE IF EXISTS " + DatabaseContract.BookEntry.TABLE_BOOKS);
        onCreate(db);
    }
}